//
//  XJIdentityUpLoadIdCardImgView.m
//  XinJiangMall
//
//  Created by RaoBo on 2018/7/7.
//  Copyright © 2018年 Tzyang. All rights reserved.
//

#import "XJIdentityUpLoadIdCardImgView.h"

// 3*3+1 十个view 累死

@interface XJIdentityUpLoadIdCardImgView()
@property (nonatomic, strong) UIView *div1; //手持身份证正面照
@property (nonatomic, strong) UIImageView *eg1Iv; //实例图片1
@property (nonatomic, strong) UIView *spaceView; // 间距

///////////
@property (nonatomic, strong) UIView *div2;
@property (nonatomic, strong) UIImageView *eg2Iv;
@property (nonatomic, strong) UIView *spaceView2;



////////////
@property (nonatomic, strong) UIView *div3;
@property (nonatomic, strong) UIImageView *eg3Iv;
@property (nonatomic, strong) UIView *spaceView3;


@end

@implementation XJIdentityUpLoadIdCardImgView


#pragma mark - 一 lazy-1
- (UIView *)div1 {
    if (!_div1) {
        _div1 = [UIView new];
        _div1.backgroundColor = [UIColor whiteColor];
    }
    return _div1;
}
- (UIImageView *)eg1Iv {
    if (!_eg1Iv) {
        _eg1Iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"certified_pic1"]];
    }
    return _eg1Iv;
}
- (UIImageView *)fromtIv {
    if (!_fromtIv) {
        _fromtIv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"身份证正面照"]];
        _fromtIv.userInteractionEnabled = YES; //打开交互
    }
    return _fromtIv;
}
- (UIView *)spaceView {
    if (!_spaceView) {
        _spaceView = [UIView new];
        _spaceView.backgroundColor = [UIColor whiteColor];
    }
    return _spaceView;
}

#pragma mark - 一 lazy-2
- (UIView *)div2 {
    if (!_div2) {
        _div2 = [UIView new];
    }
    return _div2;
}
- (UIImageView *)eg2Iv {
    if (!_eg2Iv) {
        _eg2Iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"certified_pic1"]];
    }
    return _eg2Iv;
}

- (UIImageView *)backIv {
    if (!_backIv) {
        _backIv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"身份证反面照"]];
        _backIv.userInteractionEnabled = YES;
    }
    return _backIv;
}
- (UIView *)spaceView2 {
    
    if (!_spaceView2) {
        _spaceView2 = [UIView new];
        _spaceView2.backgroundColor = [UIColor whiteColor];
    }
    return _spaceView2;
}

#pragma mark - 一 lazy-3
- (UIView *)div3 {
    if (!_div3) {
        _div3 = [UIView new];
    }
    return _div3;
}
- (UIImageView *)eg3Iv {
    if (!_eg3Iv) {
        _eg3Iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"certified_pic1"]];
    }
    return _eg3Iv;
}
- (UIView *)spaceView3 {
    if (!_spaceView3) {
        _spaceView3 = [UIView new];
        _spaceView3.backgroundColor = [UIColor whiteColor];
    }
    return _spaceView3;
}

- (UIImageView *)handIv {
    if (!_handIv) {
        _handIv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"手持身份证照"]];
        _handIv.userInteractionEnabled = YES;
    }
    return _handIv;
}

#pragma mark - 一 lazy-4

- (UIButton *)idUploadIdCardViewNextBtn {
    if (!_idUploadIdCardViewNextBtn) {
        _idUploadIdCardViewNextBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _idUploadIdCardViewNextBtn.backgroundColor = XJCOLOR_RGB(255, 218, 6);
        _idUploadIdCardViewNextBtn.layer.masksToBounds = YES;
        _idUploadIdCardViewNextBtn.layer.cornerRadius = 10;
        [_idUploadIdCardViewNextBtn setTitle:@"下一步" forState:(UIControlStateNormal)];
        [_idUploadIdCardViewNextBtn setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
    }
    return _idUploadIdCardViewNextBtn;
}





#pragma mark - 二 init
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupView];
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}

- (void)setupView {
    
    [self addSubview:self.div1];
    [self addSubview:self.div2];
    [self addSubview:self.div3];
    
    // 手持身份证正面
    [self.div1 addSubview:self.eg1Iv];
    [self.div1 addSubview:self.spaceView];
    [self.div1 addSubview:self.fromtIv];
    
    
    //身份证背面
    [self.div2 addSubview:self.eg2Iv];
    [self.div2 addSubview:self.spaceView2];
    [self.div2 addSubview:self.backIv];
    
    
    //手持身份证
    [self.div3 addSubview:self.eg3Iv];
    [self.div3 addSubview:self.spaceView3];
    [self.div3 addSubview:self.handIv];
    
    
    
    [self addSubview:self.idUploadIdCardViewNextBtn];
}

#pragma mark - 三 layout
- (void)layoutSubviews {
    [super layoutSubviews];
    
    CGFloat k15 = 15.0;
    CGFloat k100 = (KWidth - k15*4) / 2;
    CGFloat k40 = 100.0;
    
    [self.div1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(k15);
        make.right.equalTo(self.mas_right).offset(-k15);
        make.top.equalTo(self.mas_top).offset(20);
        make.height.equalTo(@(k40));
    }];
    
    [self.eg1Iv mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.bottom.equalTo(self.div1);
        make.right.equalTo(self.spaceView.mas_left);
    }];
    
    //中间间距 30
    [self.spaceView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.div1);
        make.size.mas_equalTo(CGSizeMake(20, 30));
    }];
    
    [self.fromtIv mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.top.bottom.equalTo(self.div1);
        make.left.equalTo(self.spaceView.mas_right);
        make.width.equalTo(self.eg1Iv.mas_width);
    }];
    
    
    
    
    
    
    [self.div2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(k15);
        make.right.equalTo(self.mas_right).offset(-k15);
        make.top.equalTo(self.div1.mas_bottom).offset(20);
        make.height.equalTo(@(k40));
    }];
    [self.eg2Iv mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.bottom.equalTo(self.div2);
        make.right.equalTo(self.spaceView2.mas_left);
    }];
    //中间间距 30
    [self.spaceView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.div2);
        make.size.mas_equalTo(CGSizeMake(20, 30));
    }];
    [self.backIv mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.top.bottom.equalTo(self.div2);
        make.left.equalTo(self.spaceView2.mas_right);
        make.width.equalTo(self.eg2Iv.mas_width);
    }];
    
    
    
    
    
    
    
    [self.div3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(k15);
        make.right.equalTo(self.mas_right).offset(-k15);
        make.top.equalTo(self.div2.mas_bottom).offset(20);
        make.height.equalTo(@(k40));
    }];
    [self.eg3Iv mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.bottom.equalTo(self.div3);
        make.right.equalTo(self.spaceView3.mas_left);
    }];
    //中间间距 30
    [self.spaceView3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.div3);
        make.size.mas_equalTo(CGSizeMake(20, 30));
    }];
    [self.handIv mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.top.bottom.equalTo(self.div3);
        make.left.equalTo(self.spaceView3.mas_right);
        make.width.equalTo(self.eg3Iv.mas_width);
    }];
    
    
    [self.idUploadIdCardViewNextBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(k15);
        make.right.equalTo(self.mas_right).offset(-k15);
        make.top.equalTo(self.div3.mas_bottom).offset(20);
    }];
}


@end
